sysroot: Reject attempts to pin the staged deployment
authorColin Walters <walters@verbum.org>
Thu, 28 Jun 2018 19:18:27 +0000 (15:18 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 29 Jun 2018 01:52:30 +0000 (01:52 +0000)
From https://github.com/projectatomic/rpm-ostree/pull/1434#discussion_r198936674

To support it we'd have to actually write it to disk, which...let's
not try that right now.

Closes: #1660
Approved by: jlebon

src/libostree/ostree-sysroot.c
tests/installed/destructive/staged-deploy.yml

index 707b161f75304327737abd3f7186a305ba0f88a5..4b2c654ca695758ed952970fa2963730231e1a81 100644 (file)
@@ -1894,7 +1894,8 @@ ostree_sysroot_deployment_unlock (OstreeSysroot     *self,
  * for e.g. older versions of libostree unaware of pinning to GC the deployment.
  *
  * This function does nothing and returns successfully if the deployment
- * is already in the desired pinning state.
+ * is already in the desired pinning state.  It is an error to try to pin
+ * the staged deployment (as it's not in the bootloader entries).
  *
  * Since: 2018.3
  */
@@ -1908,6 +1909,9 @@ ostree_sysroot_deployment_set_pinned (OstreeSysroot     *self,
   if (is_pinned == current_pin)
     return TRUE;
 
+  if (ostree_deployment_is_staged (deployment))
+    return glnx_throw (error, "Cannot pin staged deployment");
+
   g_autoptr(OstreeDeployment) deployment_clone = ostree_deployment_clone (deployment);
   GKeyFile *origin_clone = ostree_deployment_get_origin (deployment_clone);
 
index f34550a2a2bea2d390d903290782f868e9e5e2af..8802fb1b650b8a51fe849ff57df2cf3a1549d378 100644 (file)
     done
     test -f deployment-ref-found
     rm deployment-ref-found
+    if ostree admin pin 0 2>err.txt; then
+      echo "Pinned staged deployment"; exit 1
+    fi
+    grep -qFe 'Cannot pin staged deployment' err.txt
   environment:
     commit: "{{ rpmostree_status['deployments'][0]['checksum'] }}"
 - include_tasks: ../tasks/reboot.yml